package com.example.mvpdemo.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;

public abstract class BaseMvpActivity<T extends BasePresenter> extends BaseActivity  {

    private static final String TAG = "BaseMvpActivity";
    protected T mPresenter;

    /***
     * 初始化presenter
     */
    protected abstract void initPresenter();

    /***
     * 填充布局
     */
    protected abstract void fillLayout();

    /***
     * 初始化view
     */
    protected abstract void initView();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        fillLayout();
        initPresenter();
        initView();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null && mPresenter.isViewAttached()) {
            mPresenter.detachView();
            mPresenter = null;
            Log.e(TAG, "onDestroy");
        }
    }

}
